from jsonpath import jsonpath
from fake_useragent import *
import requests

# jsonpath的使用

url = "https://www.lagou.com/lbs/getAllCitySearchLabels.json"
headers = {
    "User-agent": UserAgent().chrome
}
response = requests.get(url, headers=headers)
names = jsonpath(response.json(), "$..name")
codes = jsonpath(response.json(), "$..code")

for name, code in zip(names, codes):
    print(f"{name} : {code}")
